import 'package:acgn_pioneer/pages/account/credit_mixin.dart';
import 'package:flutter/material.dart';
import '../../public.dart';

class CreditPage extends StatefulWidget {
  CreditPage({Key key}) : super(key: key);
  @override
  _CreditPageState createState() => _CreditPageState();
}

class _CreditPageState extends State<CreditPage>
    with AutomaticKeepAliveClientMixin, CreditMixin<CreditPage> {
  @override
  void initState() {
    super.initState();
    getUserScore(0);
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    user = Provider.of<UserProvider>(context);
    return Column(children: [
      Container(
          height: 40,
          margin: EdgeInsets.only(top: 12),
          padding: EdgeInsets.only(left: 16, right: 16),
          color: ColorUtil.rgba(18, 18, 26, 1),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Row(children: [
                Text('积分仅30天内有效，请尽快提现 ',
                    style:
                        TextStyle(color: ColorUtil.rgba(255, 255, 255, 0.6))),
                GestureDetector(
                  onTap: _expiredTips,
                  child: SVG.icon('help',
                      color: ColorUtil.rgba(255, 255, 255, 0.6)),
                )
              ]),
              GestureDetector(
                onTap: () {
                  Routers.navigateTo(RouterPage.MY_CREDIT);
                },
                child: Row(children: [
                  Text('过期记录',
                      style:
                          TextStyle(color: ColorUtil.rgba(255, 255, 255, 0.6))),
                  SVG.icon('arrow_right',
                      size: 12, color: ColorUtil.rgba(255, 255, 255, 0.6))
                ]),
              )
            ],
          )),
      Expanded(child: commonBuild(context))
    ]);
  }

  _expiredTips() {
    ACGN.toast.dialog(context,
        constraints: BoxConstraints(maxWidth: 280),
        actions: [
          Expanded(
              child: FlatButton(
            height: 48,
            color: Colors.transparent,
            shape:
                RoundedRectangleBorder(borderRadius: BorderRadius.circular(0)),
            child: Text(
              '知道了',
              style: TextStyle(color: Colors.white, fontSize: 16),
            ),
            onPressed: () {
              Navigator.of(context).pop();
            },
          )),
        ],
        title: '积分过期说明',
        content:
            Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
          Text('积分有效期',
              style: TextStyle(
                color: Colors.white,
              )),
          RichText(
              text: TextSpan(children: [
            TextSpan(
                text: '1、积分',
                style: TextStyle(
                  height: 2.5,
                )),
            TextSpan(
              text: '30天内有效',
              style: TextStyle(
                  color: ColorUtil.rgba(255, 215, 59, 1),
                  textBaseline: TextBaseline.alphabetic),
            ),
            TextSpan(text: '，请尽快提现'),
          ])),
          Text('2、提现时，优先使用快过期的积分',
              style: TextStyle(
                height: 1.5,
                color: Colors.white,
              )),
          Text('如有疑问，请咨询客服400-616-1961',
              style: TextStyle(
                height: 1.5,
                color: Colors.white,
              )),
        ]));
  }

  @override
  bool get wantKeepAlive => true;
}
